﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WF = CPPEI.WorkflowCore;

namespace Demo.AUDITANDREJECTWITHACTORS
{
    public partial class Draft : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void _ctlBtnSubmit_Click(object sender, EventArgs e)
        {
            Bill bill = new Bill();
            UIToModel(bill);

            WF.Instance instance = WF.Engine.Start(Global.WF_AUDITANDREJECTWITHACTORS,
                new WF.Actor("user01", "用户01", WF.ActorType.User),
                bill);

            string targetUrl = string.Format("{0}?wf:instance={1}", instance.State.Activity.Property.Page.Address, instance.Id);

            Response.Redirect(targetUrl);
        }

        private void UIToModel(Bill bill)
        {
            bill.Content = _ctlContent.Text;
            bill.CreatedTime = DateTime.Now;
            bill.Creator = _ctlEditCreator.Text;
        }
    }

    public class Bill
    {
        public string Content { get; set; }
        public string Creator { get; set; }
        public DateTime CreatedTime { get; set; }
    }
}